#include<stdio.h>
#include<unistd.h>

int g_val = 100;

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        int cnt = 6;
        while(cnt--)
        {
            printf("I am a child process! g_val = %d, &g_val = %p\n", g_val, &g_val);
            sleep(1);
            
            if(cnt == 3) 
            {
                g_val = 200;
                printf("child modify g_val: 100->200\n");
            }
        }
    }
    else
    {
        int cnt = 6;
        while(cnt--)
        {
            printf("I am a father process! g_val = %d, &g_val = %p\n", g_val, &g_val);
            sleep(1);

        }
    }

    return 0;
}
